package com.fenghongzhang.day005;

import android.os.Bundle;
import android.view.View;
import android.widget.RatingBar;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import java.util.regex.Pattern;

public class Main2Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        RatingBar ratingBar = findViewById(R.id.bar);
        float rating = ratingBar.getRating();
//        Toast.makeText(this, rating+"", Toast.LENGTH_SHORT).show();

        //指定位置
//        Toast toast = Toast.makeText(this, "weizhi", Toast.LENGTH_SHORT);
//        toast.setGravity(Gravity.CENTER,0,-300);
//        toast.show();

//        Toast.makeText(Main2Activity.this, rating+"", Toast.LENGTH_SHORT).show();



        String s = "^[0-9A-Za-z]{6,12}$";

        boolean name = Pattern.matches(s, "name1212");
        if(name){ //

        }


        //自定义
        Toast toast1 = new Toast(this);

        //如果把一个xml -> view
        //布局填充器. 打气筒
        View inflate = getLayoutInflater().inflate(R.layout.toast_layout, null);
        toast1.setView(inflate);

        //时长
        toast1.setDuration(Toast.LENGTH_SHORT);

        //显示
        toast1.show();




        ratingBar.setRating(1);

        ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                Toast.makeText(Main2Activity.this, rating+"", Toast.LENGTH_SHORT).show();
            }
        });

    }
}
